<?php
// 本类由系统自动生成，仅供测试用途
class PowerAction extends CommonAction {

   function powerlist()
   {
   		$mpower=M('power');
   		$list =$mpower->order('type asc')->select();
   		$this->assign('list',$list);
   		$this->display();
   }

   function memberlist()
   {
   		if($_REQUEST['XXMC'] != null && $_REQUEST['XXMC'] != ""){
			$map['XXMC'] = array('like','%'.$_REQUEST[XXMC].'%');
			$this->assign('XXMC',$_REQUEST['XXMC']);
		}
		if($_REQUEST['sheng'] != null && $_REQUEST['sheng'] != ""){
			$map['quyu']  = array('like','%'.$_REQUEST[sheng].'%');
		}
		if($_REQUEST['shi'] != null && $_REQUEST['shi'] != ""){
			$map['quyu']  = array('like','%'.$_REQUEST[shi].'%');
		}
		if($_REQUEST['qu'] != null && $_REQUEST['qu'] != ""){
			$map['quyu']  = array('like','%'.$_REQUEST[qu].'%');
		}

		if($_REQUEST['sid'] != null && $_REQUEST['sid'] != "" ){
			$map['id']  = $_REQUEST['sid'];
			$this->assign('sid',$_REQUEST['sid']);
		}

//		print_r($map);

		$m = M('school');
		$list = $this->_listpage($m,$map);
		$this->display();	
   }

   function editpower()
   {
   		$id = $this->_isempty($_GET['id'],'ID不能为空');
		$m = M('school');
		$list = $m->find($id);
		$this->assign('list',$list);

		//$mpower=M('power');
   		// $splist =$mpower->where('type=1')->select();
   		// $this->assign('splist',$splist);
   		
   		//$tplist =$mpower->where('type=2')->select();
   		// $this->assign('tplist',$tplist);
   		
   		$this->display();
   }
   function savepower()
   {
   		$id = $this->_isempty($_REQUEST['id'],'ID不能为空');
   		$data =$this->_post();
   		$powerlist =$data['powerid'];
   		foreach ($powerlist as $vl) {
   			$power .= $vl.',';
   			# code...
   		}
   		$power =rtrim($power,',');
   		$datasc['power']=$power;
   		$mschool=M('school');
   		$mschool->where('id='.$id)->save($datasc);
   		$this->success('操作成功');
		
   }


}